'use strict';{let k,q=(a,b)=>_pd(["scrtEdtr",a],k[a]=b),h=a=>$(a).closest("scriptEditor"),l=a=>_pu(h(a).find("[name=scriptId]")[0]),O=a=>h(a).find("[srcFile] [type=text]").val().trim(),v=a=>h(a).find("editPane > toolbar"),m=a=>{a=$("editPane",h(a));return $(".CodeMirror",a)[0]||$("textarea",a)[0]},B=a=>{a=m(a);return[a.offsetWidth,a.offsetHeight]},r=a=>a&&!a.isClean()&&!a.isReadOnly(),p=a=>b=>{!a||r(m(a).cmObj)?_Yo("","Unsaved changes in the current script will be lost. <hr b=3> Discard changes?")(b):
b(!0)},w=function(a,b){if(!b)return $("codeField > textarea",h(a)).val();a=m(a);return a.cmObj?a.cmObj.getValue():a.value},t=function(a){a=m(a);"hidden"!=$(a).css("visibility")&&$(a).is(":visible")&&(a.cmObj?a.cmObj.focus():(a.selectionStart==a.value.length&&a.selectionEnd==a.value.length&&a.setSelectionRange(0,0),a.focus()))},C=function(a,b,c){a=m(a);a.cmObj?a.cmObj.setSize(b,c):$(a).css({width:b,height:c})};var _Tk=_wj(function*(a,b){let c=yield _5k({scriptId:a},!0);$(c).attr("helpCtx","actions/actList/runScript");
let d=_4f(b?"":"Script Editor",c,"",!0,k.boxSize||[732,520],k.boxPos).Show(!1),e=(Math.random()+"").substr(2);$(d).attr("UID",e).on("close",()=>$(window).off("."+e).delEvtCapture("."+e)).on("redimDone",function(){q("boxSize",[this.offsetWidth,this.offsetHeight]);q("boxPos",[this.offsetLeft,this.offsetTop])});$(window).captureTgtEvt("close."+e,`[UID=${e}]`,(f,g)=>{!g&&r(m(c).cmObj)&&(f.stopPropagation(),p()(P=>{P&&$(d).triggerEvt({close:!0})}))}).on("beforeunload."+e,f=>{if(r(m(c).cmObj))return"Unsaved changes in the current script will be lost."});
$("diagFrm > header ctrls",d).prepend('\n <b popout title="Pop out"></b>\n <b maximize title="Maximize"></b>\n <b restore title="Restore"></b>\n ').on("click","[popout]",_Et(function*(){if(yield p(c))window.open("#script="+l(c),"_blank"),_5p(d)})).on("click","[maximize], [restore]",()=>{$(d).toggleClass("maximized")});b&&(yield _Pi(150),$("diagFrm > header [maximize]",d)[0].click())}),_5k=_wj(function*(a,b=!1){let {scriptId:c,bkgrnd:d,async:e}=a;k={theme:"default ACtrl-soft",lnWrap:!1,lint:!0}.add(yield _qf("scrtEdtr"));
c||(yield _1i("script"),c=yield f=>D(f));a=_er(c,"script");a.value||(a.value={});x(c,a.value);a=_Bj(_lo)`\n <scriptEditor hideEditPane ${b?"rich":""} class="${b?k.theme:""}">\n <header>\n <div scriptSel>\n <tag>Script:</tag>\n <btnFld grow name=scriptId value="${c}">\n <input type=text field grow value="${_5h(a.name||"")}" placeholder="(unnamed script)" ${a.value.isCustom?"":"readonly"}><b button></b>\n </btnFld> <h h=name></h>\n </div>\n <div actionOpts>\n <tag>${_io("bkgrnd",d)}Run in background</tag> <h h=bkgr></h> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\n <tag>${_io("async",
e)}Run asynchronously</tag> <h h=asyn></h>\n </div>\n </header>\n ${E(a.value)}\n <footer DataModule>\n <div tabSel>\n <sSel grow><select style="visibility: hidden"></select><select tabs unset><option value=_>Choose a tab to test run the script...</select></sSel>\n <button testRun>Run</button> <h h=run></h> <button richEdit title="Open the script in the script editor">Script Editor</button>\n </div>\n </footer>\n </scriptEditor>\n `;b||(yield _Pi(0));Q(a);return a[0]});let Q=function(a){a.on("mousedown change",
"select:not([tabs])",function(b){$(this).is(":focus")&&(t(this),b.preventDefault())}).on("mousedown change","[tabs]",function(b){300<Date.now()-(this.lastUpdate||0)&&($(this).is(":focus")?t(this):_By({url:["http://*/*","https://*/*","file:///*"]})(c=>{let d=this.value;$(":not(:first-child)",this).remove();c.unshift({id:0,title:"<< Background >>"});c.forEach(e=>this.options.add(new Option(e.title,e.id,!1,e.id==d)));this.lastUpdate=Date.now();_hf._So(_Ld,[_mw,_mw|_Go])}),b.preventDefault());$(this).attr("unset",
Number.isInteger(+this.value)?null:"")}).on("mousedown","[scriptSel] btnFld [button]",function(){let b=this.closest("[name]");R(b,a.is("[rich]"))(c=>{_Jh(c,b,"b)t)r<l< ,HR,VR","borderAndShadowSimple noTail");$("item[selected]",c).each(function(){this.scrollIntoViewIfNeeded(!0)})})}).on("mousedown","[scriptSel] btnFld input[readonly]",function(){$(this).siblings("[button]").triggerEvt("mousedown",!0)}).on("input","[name=scriptId]",_Ow(200,function(){_nd(function*(){let b=$("[type=text]",this)[0],c=
b.value.trim(),d=_pu(this),[e,f]=yield _Ze(d,c);f&&(b.value=f);if(!e)return!1;_we([d,"name"],c,0,()=>{a.triggerEvt("input",!0);a.is("[rich]")&&!_st(location)&&_My.updActLbl(d)})},[],this);return!1},()=>!1)).on("input","[srcFile] [type=text]",_Ow(600,function(b){F(this,!0)})).on("input","codeField > textarea",_se(400,function(b){G(this)()})).on("keydown","codeField > textarea",function(b){9==b.keyCode?(this.setRangeText("\t",this.selectionStart,this.selectionEnd,"end"),b.preventDefault(),$(this).triggerEvt("input",
!0)):82==b.keyCode&&b.ctrlKey&&(y(this),b.preventDefault())}).on("change","[srcFile] [type=checkbox]",function(b){$(this).parent().attr("checked",this.checked?"":null);F(this)}).on("click","[testRun]",function(){y(this)}).on("click","[richEdit]",function(){_Tk(l(this))()}).on("click","tag",function(b){$(b.target).is("input")||$("input",this).click()}).on("mousedown",function(b){b.target.closest(".CodeMirror, textarea")||$(b.target).is("[type=text], select")||(b.preventDefault(),t(this))}).on("focusGained",
function(){t(this)})},y=_Et(function*(a){let b=h(a).find("[tabs]"),c=+b.val();Number.isInteger(c)?(0!=c&&(yield d=>_hf._vi(d),_hf._pi([c],_hf._Tt)),_hf._Qd(l(a),c,[c],w(a,!0)).then(_Qu,_Qu)):(b.addClass("highlight"),yield _Pi(350),b.removeClass("highlight"))}),x=function(a,b){_xp(a)&&Object.defineProperty(b,"isCustom",{value:!0});return b},u=function(a){var b=h(a);b=$("[srcFile] [type=checkbox]",b)[0].checked?{srcFile:O(b)}:{srcCode:w(b),mdTime:Date.now()};return x(l(a),b)},G=_wj(function*(a){var b=
u(a);if(b.srcFile){a=w(a);b=yield _hf._9y(b.srcFile);let c=(_7s(b)||{}).encode,d=yield _hf._ok(b,_uu(a,c));if(d)return a=yield _hf._fw(_r,+d),_yt("Error saving the file. <hr b=2>"+a,{type:"error"}),!1;_7s(b,{srcCode:a,encode:c,ldTime:Date.now()})}else _we([l(a),"value"],b);return!0}),F=function(a,b){a=h(a);let c=$("> content > editPane",a)[0],d=!b&&c.otherEditPane?c.otherEditPane:H(u(a).del("srcCode"),!1)[0];d.otherEditPane=b?c.otherEditPane:c;b=B(a);c.parentNode.replaceChild(d,c);C(a,...b);a.attr("hideEditPane",
a.find("msg:not(:empty)")[0]?"":null);_we([l(a),"value"],u(a))},E=function(a){a=_Bj(_lo)`\n <content DataModule>\n <div srcFile ${a.isCustom?"":"greyedout"}>\n <tag ${"srcFile"in a?"checked":""}>${_io("","srcFile"in a)}External file:</tag>\n <btnFld popupAround grow>${_eu("",a.srcFile||"","Enter a file path or URL...","Javascript files: *.js, All Files: *.*","grow","locPlhlr")}<b button></b></btnFld> <h h=file></h>\n </div>\n ${H(a)}\n </content>\n `;_hs($("btnFld",a),"b)t)r<l<","L_desk L_doc L_prof L_app L_win L_drv L_prg86 L_rec L_star L_tmp".split(" "),
!1);return a},H=function(a,b=!0){let c=_Bj(_lo)`\n <editPane>\n <msg type=busy>${_Ou("busySign")}</msg>\n <toolbar><btn><i>&nbsp;</i></btn></toolbar>\n <codeField>\n <textarea ${_Zk(a.srcFile)&&!_0j(a.srcFile)||!a.isCustom?"readonly":""} spellcheck=false></textarea>\n </codeField>\n </editPane>\n `;I(a)(_Et(function*(d){let e=$("textarea",c).val(d.srcCode)[0];yield _Pi(0);h(c).is("[rich]")&&(yield f=>S(f),T(e,b));U(c,d.error)}));return c},U=function(a,b){h(a).attr("hideEditPane",b?"":null).find("editPane > msg").attr("type",
"error").html(b||"")};const J={esversion:55>_Ok?7:9,asyncWrap:55<=_Ok,undef:!0,unused:!0,browser:!0,devel:!0,debug:!0,evil:!0,withstmt:!0,globals:{ACtl:!1}};let T=_Et(function*(a,b=!0){const c=a.offsetWidth,d=a.offsetHeight;let e=$(a).is("[readonly]"),f=CodeMirror.fromTextArea(a,{readOnly:e,lineNumbers:!0,indentWithTabs:!0,indentUnit:4,smartIndent:!1,matchBrackets:!0,foldGutter:!0,cursorBlinkRate:e?-1:400,cursorHeight:.9,theme:k.theme,lineWrapping:k.lnWrap,lint:k.lint?J:void 0,gutters:["CodeMirror-lint-markers",
"CodeMirror-linenumbers","CodeMirror-foldgutter"],extraKeys:{"Ctrl-O":K,"Ctrl-S":L,"Ctrl-R":g=>y(g.getWrapperElement())},showCursorWhenSelecting:!0});a=f.getWrapperElement();a.cmObj=f;f.setSize(c,d);(new ResizeObserver(g=>{g=g[0].contentRect;f.setSize(g.width,g.height)})).observe(a.parentElement);V(a);yield g=>_Bd(g);yield _Pi(100);f.refresh();b&&f.focus();M(a,400)}),K=_Et(function*(a){a=a.getWrapperElement();if(yield p(a)){let b=u(a);b.srcFile&&_7s(yield _hf._9y(b.srcFile),void 0);z(a,l(a))}}),V=
function(a){let b=a.cmObj;v(a).html(`\n <btn act=reopen title="Reopen (Ctrl+O)"><i>&#59950;</i></btn>\n <btn act=save disabled title="Save (Ctrl+S)"><i>&#xE962;</i></btn>\n <btn act=undo disabled title="Undo (Ctrl+Z)"><i blue>&#xE967;</i></btn>\n <btn act=redo disabled title="Redo (Ctrl+Shift+Z)"><i blue>&#xE968;</i></btn>\n <btn act=foldAll disabled title="Fold all"><i>&#xEA88;</i></btn>\n <btn act=unfoldAll disabled title="Unfold all"><i>&#xEA87;</i></btn>\n <btn act=pretty title="Pretty format"><i>{}</i></btn>\n <btn swch=lint ${k.lint?
"checked":""} title="Syntax check"><i>&#xEA12;</i></btn>\n <btn swch=lnWrap ${k.lnWrap?"checked":""} title="Line wrap"><i>&#xEA76;</i></btn>\n <tag opt=theme>Theme: ${_ow({"default ACtrl-light":"Light","default ACtrl-soft":"Almond","default ACtrl-dark":"Dark"},k.theme)}</tag>\n `).on("click","[act]",function(){switch($(this).attr("act")){case "reopen":K(b);break;case "save":L(b);break;case "undo":b.undo();break;case "redo":b.redo();break;case "foldAll":b.execCommand("foldAll");A(a);break;case "unfoldAll":b.execCommand("unfoldAll");
A(a);break;case "pretty":b.setValue(W(b.getValue())),M(a,1E3)}}).on("mousedown","[swch]",function(){let c=$(this).attr("swch"),d=null==$(this).attr("checked");$(this).attr("checked",d?"":null);q(c,d);switch(c){case "lint":b.setOption(c,d?J:void 0);break;case "lnWrap":b.setOption("lineWrapping",d)}}).on("change","[opt]",function(c){let d=$(this).attr("opt");switch(d){case "theme":b.setOption("theme",c.target.value),h(this).attr("class",c.target.value),q(d,c.target.value)}});b.on("change",(c,d)=>N(c));
b.on("fold",c=>setTimeout(()=>n(b.getWrapperElement())));b.on("unfold",c=>setTimeout(()=>n(b.getWrapperElement())))},W=function(a){return js_beautify(a,{indent_with_tabs:!0,end_with_newline:!0,wrap_line_length:120})},N=_Ow(250,a=>{let {undo:b,redo:c}=a.historySize(),d=v(a.getWrapperElement());$("[act=save]",d).attr("disabled",r(a)?null:"");$("[act=undo]",d).attr("disabled",b?null:"");$("[act=redo]",d).attr("disabled",c?null:"");A(a.getWrapperElement())}),n=function(a){let b=v(a),c=a.querySelector(".CodeMirror-foldgutter-folded");
a=a.querySelector(".CodeMirror-foldgutter-open");$("[act=foldAll]",b).attr("disabled",a?null:"");$("[act=unfoldAll]",b).attr("disabled",c?null:"")},A=_se(700,n),M=function(a,b){setTimeout(()=>n(a),b);setTimeout(()=>n(a),2*b);setTimeout(()=>n(a),3*b)},L=function(a){a.isClean()||(a.save(),G(a.getWrapperElement())(b=>{b&&(a.markClean(),N(a))}))},R=_wj(function*(a,b){let c=_pu(a),d=_wj(function*(e,f){f||(f=_er(e));let g=yield I(f.value,!0);return`\n <item ${_xp(e)?"custom":""} value="${e}" ${e==c?"selected":
""}>\n <div><l>${f.name}</l> <br>\n <size>${g&&!g.error?_jj(g.srcCode.length)+"B":""}</size>\n <date>${g&&!g.error?`${g.ldTime?"Loaded":"Modified"} ${_br(new Date(g.ldTime||g.mdTime))}`:""}</date>\n </div> <del button title="Delete"></del>\n </item>\n `});return _lo(yield _Bj`\n <namedEntityMenu script DataModule>\n ${[..._hf._2i.script].map(e=>d(...e))}\n ${[..._Ws("script",!0)].map(e=>d(e))}\n ${$("[type=text]",a).val().trim()||b?"<newEntity>New script...</newEntity>":""}\n </namedEntityMenu>\n `).on("click",
"del",function(e){e.stopImmediatePropagation()}).on("dblclick","del",function(){let e=_pu(this.closest("item"));_hg(e,()=>$(this).closest("item").remove())}).on("click","item:not([selected])",function(){p(a)(e=>{e&&(z(a,_pu(this)),_ke())})}).on("click","newEntity",function(){p(a)(e=>{e&&D(f=>{z(a,f);_ke()})})})}),z=function(a,b){let c=_er(b,"script");x(b,c.value);a=h(a);a.find("[name=scriptId]").val(b).triggerEvt("change",!0).find("[type=text]").val(c.name).prop("readOnly",!c.value.isCustom);let d=
B(a);a.attr("hideEditPane","").find("> content").replaceWith(E(c.value));C(a,...d);_st(location)&&(location.hash="script="+b)},D=function(a){_cy("script",{srcCode:"//example script\nalert('Hello, world!') ;\n",mdTime:Date.now()})(b=>{_c(b)();a(b)})},I=_wj(function*(a,b){if(!("srcFile"in a))return a;if(!a.srcFile)return{error:"Local files can be viewed and edited here. <br> URLs can be viewed but not edited."};a=yield _hf._9y(a.srcFile);if(b)return _7s(a);b=yield _hf._ka(a);null!=b.error&&(b.error=
_0j(a)||!_Zk(a)?yield _hf._fw(_r,b.error):_1k(b.error));return b}),S=function(a){let b=["https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.4/codemirror.min.css","https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.4/addon/fold/foldgutter.min.css","https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.4/addon/lint/lint.min.css"],c="https://cdnjs.cloudflare.com/ajax/libs/jshint/2.10.2/jshint.min.js https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.2/beautify.min.js https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.4/mode/javascript/javascript.min.js https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.4/addon/edit/matchbrackets.min.js https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.4/addon/fold/foldcode.min.js https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.4/addon/fold/foldgutter.min.js https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.4/addon/fold/brace-fold.min.js https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.4/addon/fold/indent-fold.min.js https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.4/addon/fold/comment-fold.min.js https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.4/addon/lint/lint.min.js /res/javascript-lint.min.js".split(" ");
_nu(_zy("/file26.css"),_R("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.4/codemirror.min.js"),_Pi(150))(()=>_nu(b.map(_zy),c.map(_R),_Pi(100)))(a)}};
